package logic

import (
	"context"
	"video-hub/model/mysql"

	"video-hub/videorpc/internal/svc"
	"video-hub/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoAddLogic {
	return &VideoAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoAddLogic) VideoAdd(in *videorpc.VideoAddRequest) (*videorpc.VideoAddResponse, error) {
	// todo: add your logic here and delete this line
	video := mysql.Video{
		UserId:        int(in.UserId),
		VideoTitle:    in.VideoTitle,
		VideoCategory: in.VideoCategory,
	}
	err := video.VideoAdd(mysql.DB)
	if err != nil {
		return nil, err
	}
	return &videorpc.VideoAddResponse{
		VideoId: int64(video.ID),
	}, nil
}
